#include "mainwindow.h"
#include "ui_mainwindow.h"

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);

    QMenuBar* menuBar = new QMenuBar();
    this->setMenuBar(menuBar);

    QMenu* mp = new QMenu("父菜单");
    QMenu* mc = new QMenu("子菜单");

    menuBar->addMenu(mp);
    mp->addMenu(mc);

    QAction* a1 = new QAction("菜单项1");
    QAction* a2 = new QAction("菜单项2");
    mc->addAction(a1);
    mc->addAction(a2);

    QMenu* mc2 = new QMenu("子菜单2");
    mc->addMenu(mc2);

}

MainWindow::~MainWindow()
{
    delete ui;
}

